package beautiful.butterfly.server.httpserver.mvc.http;


import beautiful.butterfly.server.httpserver.mvc.multipart.FileItem;
import io.netty.buffer.ByteBuf;
import lombok.NonNull;

import java.util.List;
import java.util.Map;


public interface Request {

    String query(@NonNull String name);

    Request setAttribute(@NonNull String name, Object value);

    /**
     * Get client host.
     */
    String host();


    /**
     * Get getRequest getUri
     */
    String getUri();

    /**
     * Get getRequest getUrl
     */
    String getUrl();


    /**
     * Get current getRequest Actions params, like /users/:uid
     *
     * @return Return parameterMap on the path Map
     */
    Map<String, String> pathParams();


    /**
     * Get queryString. e.g: http://xxx.com/hello?name=a&age=23
     *
     * @return Return query string
     */
    String queryString();

    /**
     * Get current getRequest query parameterMap
     *
     * @return Return getRequest query Map
     */
    Map<String, List<String>> parameterMap();


    /**
     * Get current getRequest http method. e.g: GET
     *
     * @return Return getRequest method
     */
    String method();


    /**
     * Get current getRequest getSession, if null then create
     *
     * @return Return current getSession
     */
    Session getSession();


    /**
     * Get current getRequest getNameToCookieMap
     *
     * @return return getNameToCookieMap
     */
    Map<String, String> getNameToCookieMap();


    /**
     * Add a XCookie to the getRequest
     *
     * @param Cookies
     * @return return Request instance
     */
    Request cookie(Cookies Cookies);

    /**
     * Get current getRequest getHeaderMap.
     *
     * @return Return setHeader information Map
     */
    Map<String, String> getHeaderMap();


    /**
     * Get current getRequest is KeepAlive, HTTP1.1 is true.
     *
     * @return return current getRequest connection keepAlive
     */
    boolean keepAlive();

    /**
     * Get current getRequest getAttributeMap
     *
     * @return Return all Attribute in Request
     */
    Map<String, Object> getAttributeMap();


    /**
     * Get current getRequest all getFileNameToFileItemMap
     *
     * @return return getRequest file items
     */
    Map<String, FileItem> getFileNameToFileItemMap();


    /**
     * Get current getRequest body as ByteBuf
     *
     * @return Return getRequest body
     */
    ByteBuf body();

    /**
     * Get current getRequest body as string
     *
     * @return return getRequest body to string
     */
    String bodyToString();

    public String cookie(String sessionKey);

    public String header(String ifModifiedSince);

    public Object getAttribute(String name);
}
